//
//  LogViewController.m
//  iStore
//
//  Created by MacDev on 15/4/14.
//  Copyright (c) 2015年 mirrtalk. All rights reserved.
//

#import "LogViewController.h"
#import "NewLogViewController.h"
#import "RegisterViewController.h"
#import "MyUtil.h"


@interface LogViewController ()
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;

@end

@implementation LogViewController
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = YES;
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.view.backgroundColor = [UIColor whiteColor];
    [self startLog];
}
#pragma mark -- 整个布局 --
- (void)startLog
{
    
    
    NSDictionary * dic = @{@"注册":@"vtf标题-1",@"登录":@"backColor"};
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:[UIScreen mainScreen].bounds];
    imageView.image = [UIImage imageNamed:@"beijing.jpg"];
    [self.view addSubview:imageView];
    
    for (int i = 0; i<2; i++)
    {
        //加入底部按钮
        UIButton * btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        btn.frame = CGRectMake((ScreenWidth/2)*i, ScreenHeight-57, (ScreenWidth/2), 57);
        NSArray * titleArr = [dic allKeys];
        btn.titleLabel.font = kLevelButtonFont;
        if (i == 0)
        {
            [btn setTitleColor:[UIColor colorWithRed:132 /255.0 green:36/255.0 blue:40/255.0 alpha:1] forState:UIControlStateNormal];
        }
        else
        {
            [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        }
        btn.tag = i+1;
        NSLog(@"%ld",(long)btn.tag);
        [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        [btn setTitle:[titleArr objectAtIndex:i] forState:UIControlStateNormal];
        [btn setBackgroundImage:[UIImage imageNamed:[dic objectForKey:[titleArr objectAtIndex:i]]] forState:UIControlStateNormal];
        [self.view addSubview:btn];
    }
    
}

#pragma mark -- 登录或者注册 --
- (void)btnClick:(UIButton *)btn
{
    UIViewController * vc = nil;
    switch (btn.tag)
    {
        case 1:
            
            vc = [[RegisterViewController alloc]init];
            break;
        case 2:
            vc = [[NewLogViewController alloc]init];
            break;
        default:
            break;
    }
    self.navigationItem.backBarButtonItem.title = @"返回";
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end